<?php

// @TODO: 交流的相关

class talk extends controller_basic {
	
	function send() { // 交流
		$iid = isset($this->__params['iid']) ? (int)$this->__params['iid'] : 0;
		$uid = isset($this->__params['uid']) ? (int)$this->__params['uid'] : 0;
		$con = isset($this->__params['con']) ? trim(urldecode($this->__params['con'])) : '';
		
		$data = (int)mdl_bottle_session::getInstance()->say($iid, $uid, $con);
		$this->output(array( 'code' => (int)($data > 0) ));
	}
	
	function get_session() {
		$uid = isset($this->__params['uid']) ? (int)$this->__params['uid'] : 0;
		$iid = isset($this->__params['iid']) ? (int)$this->__params['iid'] : 0;
		$data = !$iid ? false : mdl_bottle_session::getInstance()->get($iid);

		$i_bottle = array();
		if($iid) $i_bottle = mdl_bottle_item::getInstance()->findOne($iid);
		 
		$data[] = $i_bottle;
		
		$this->output(array(
			'code'		=> '1',
			'datas'		=> $data,
			'iid'			=> $iid,
			'send_uid'	=> isset($i_bottle['uid']) ? (int)$i_bottle['uid'] : 0,
		));
	}
}